package com.xiaoma.service.impl;

import com.xiaoma.mapper.SoftwareCategoryMapper;
import com.xiaoma.mapper.SoftwareMapper;
import com.xiaoma.pojo.Software;
import com.xiaoma.service.SoftwareService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class SoftwareServiceImpl implements SoftwareService {
    @Autowired
    private SoftwareMapper softwareMapper;
    @Autowired
    private SoftwareCategoryMapper softwareCategoryMapper;

    /**
     * 用户所看到的软件信息
     */
    @Override
    public List<Software> getSoftware() {
        List<Software> softwares = softwareMapper.getSoftware();
        for (Software software : softwares) {
            Integer softwareId = software.getId();
            List<Integer> softwareCategoryId = softwareCategoryMapper.getSoftwareCategoryId(softwareId);
            software.setCategoryId(softwareCategoryId);
        }
        return softwares;
    }
}
